<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="background-color: #fff;">
    <input type="hidden" name="row[rid]" value="{$info.id}">
    <input type="hidden" name="row[id]" value="{$row.id}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入时间')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[date]" type="text" value="{$row.date}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入人')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-user_name" class="form-control" name="row[user_name]" type="text" value="{$row.user_name}" readonly>
            <input class="form-control" name="row[user_id]" type="hidden" value="{$row.user_id}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('类别')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select class="form-control" name="row[type]">
                <option value="">请选择类别</option>
<!--                <option value="1"  <?php if($row['type']=="1"){?> selected<?php }?>>报案</option>-->
                <option value="2" <?php if($row['type']=="2"){?> selected<?php }?>>咨询</option>
                <option value="3" <?php if($row['type']=="3"){?> selected<?php }?>>退费</option>
                <option value="4" <?php if($row['type']=="4"){?> selected<?php }?>>销案退费</option>
                <option value="5" <?php if($row['type']=="5"){?> selected<?php }?>>客服催办</option>
                <option value="6" <?php if($row['type']=="6"){?> selected<?php }?>>投诉</option>
                <option value="7" <?php if($row['type']=="7"){?> selected<?php }?>>工商投诉</option>
                <option value="8" <?php if($row['type']=="8"){?> selected<?php }?>>公众号投诉</option>
                <option value="9" <?php if($row['type']=="9"){?> selected<?php }?>>支付投诉</option>
<!--                <option value="10" <?php if($row['type']=="10"){?> selected<?php }?>>渠道催办</option>-->
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人类型')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            <input id="c-ld_type" name="row[ld_type]" type="radio" value="1" <?php if($row['ld_type']=="1"){?> checked<?php }?>>本人
            <input id="c-ld_type1" name="row[ld_type]" type="radio" value="2"<?php if($row['ld_type']=="2"){?> checked<?php }?>>他人
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人姓名')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="hidden" id="c-name1" value="{$info.learned_name}">
            <input id="c-name" class="form-control" name="row[name]" type="text" data-rule="required" value="{$row.name}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人电话')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-phone" class="form-control" name="row[phone]" type="text" data-rule="required" value="{$row.phone}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('车型')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="row[chexing]" id="c-chexing"  class="form-control" data-rule="required">
                <option value="">请选择车辆类型</option>
                <?php foreach($chexing as $k => $v){?>
                    <option value="{$v}" <?php if($row['chexing']==$v){?> selected<?php }?>>{$k}</option>
                <?php }?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-content" class="form-control" name="row[content]" type="text">{$row.content}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('查勘人')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="row[fenpei]" id="c-fenpei"  class="form-control">
                <option value="">请选择查勘人</option>
                {volist name="fenpei" id="vo"}
                <option value="{$vo.id}" <?php if($row['fenpei'] == $vo['id']){?> selected<?php }?>>{$vo.username}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="form-group" style="margin-top: 50px;padding-bottom: 50px;margin-left: 150px;">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 " style="margin: auto;">
            <button type="button" class="btn btn-primary btn-embossed " style="margin-left: 10px;" onclick="zuihou_save()">{:__('保存并关闭')}</button>
        </div>
    </div>
</form>

<script src="/assets/libs/jquery/dist/jquery.js"></script>
<script>
    function zuihou_save() {
        var formData = $("#add-form").serialize();
        $.ajax({
            url: "{:url('kf/record/save_list')}",
            data: formData,
            type: 'post',
            dataType: 'json',
            success: function (ret) {
                if (ret.code == 1) {
                    var res = ret.data
                    $('#date_'+res.id, window.parent.document).html(res.date);
                    $('#type_'+res.id, window.parent.document).html(res.type);
                    $('#ld_type_'+res.id, window.parent.document).html(res.ld_type);
                    $('#name_'+res.id, window.parent.document).html(res.name);
                    $('#phone_'+res.id, window.parent.document).html(res.phone);
                    $('#chexing_'+res.id, window.parent.document).html(res.chexing);
                    $('#fenpei_'+res.id, window.parent.document).html(res.fenpei);
                    $('#content_'+res.id, window.parent.document).html(res.content);
                    layer.msg('保存成功！', {
                        time: 1000,
                        icon: 1
                    }, function (index) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //执行关闭
                    })
                } else {
                    layer.alert(res.msg)
                }
            }
        })
    }
    $("#c-ld_type").on("click", function() {
        var name = $('#c-name1').val();
        $('#c-name').val(name)
    })
    $("#c-ld_type1").on("click", function() {
        $('#c-name').val('')
    })
</script>